<script type="text/html" template lay-done="layui.data.temporaryViewdone(d);">
<div class='temporary-viewHtml-content'>
	<div class="layui-card">
		<div class="layui-card-body layui-form" style="padding: 15px;">
			<form class="layui-form temporary-viewHtml-form" action="" lay-filter="temporary-viewHtml-form-group">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">任务名称：</label>
						<div class="layui-input-inline">
							<input disabled type="text" value='{{d.params.taskname ? d.params.taskname : ""}}' name="taskname" autocomplete="off" placeholder="请输入标题" class="layui-input">
						</div>
					</div>
					<!-- <div class="layui-inline" style="width:49%;">
						<label class="layui-form-label">是否复核：</label>
						<div class="layui-input-inline" style="width: 80px;">
							<div style="line-height: 35px;">{{ d.params.review && d.params.review === '1' ? "是" : "否"}}</div>
						</div>
						<div class="review-content">
							<span class="to-review" >附加复核人：</span>
							{{# if(d.params.review && d.params.review === '1'){ }}
								<div class="review-value-box T-event" data-target="to-review">
									{{# layui.each(d.params.wadduserMsg, function(index, item){ }}
										<span usercode="{{item.adduserdataid}}" certcode="{{item.adduserid}}">{{item.addusername}}</span>
									{{# }) }}
								</div>
							{{# }else{ }}
								<div class="review-value-box layui-bg-gray T-event" data-target="to-review">
									{{# layui.each(d.params.wadduserMsg, function(index, item){ }}
										<span usercode="{{item.adduserdataid}}" certcode="{{item.adduserid}}">{{item.addusername}}</span>
									{{# }) }}
								</div>
							{{# } }}
						</div>
					</div> -->
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">开始日期：</label>
						<div class="layui-input-inline">
							<input disabled type="text" value='{{d.params.starttime ? d.params.starttime : ""}}' name="starttime" class="layui-input temporary-form-group-startDate" lay-verify="datetime" placeholder="yyyy-MM-DD HH:mm" autocomplete="off">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">结束日期：</label>
						<div class="layui-input-inline">
							<input disabled type="text" value='{{d.params.endtime ? d.params.endtime : ""}}' name="endtime" class="layui-input temporary-form-group-endDate" lay-verify="datetime" placeholder="yyyy-MM-DD HH:mm" autocomplete="off">
						</div>
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">填报要求：</label>
					<div class="layui-input-block">
						<textarea disabled name="memo" placeholder="请输入内容" class="layui-textarea" style="min-height: 35px;">
								{{d.params.memo ? d.params.memo : ""}}
						</textarea>
					</div>
				</div>  
			</form>
			<div class="special-content">
				<div class="special-key">
					<div id="temporary-upload-filie"><i class="layui-icon"></i>附件：</div>
				</div>
				<div class="special-value">
					<div class="check-value-box temporary-update-files">
						{{#
							if(d.params.fileMsg && d.params.fileMsg.length > 0){
								layui.each(d.params.fileMsg, function(index,item) {
						}}
								<div class="unit-content">
									<a class="T-event" data-target="download" href="javascript: void(0);" data-url="{{item.url}}">{{item.filename}}</a>
									<i class="layui-icon layui-icon-close T-event" data-target="delFile" data-deptid="{{item.servername}}"></i>
								</div>
						{{#
								})
							}
						}}
					</div>
				</div>
			</div>
			<div class="special-content clearfix" style="position:relative;margin:0;">
				<div class="special-key">
					<div><i class="layui-icon">&#xe608;</i>下发单位</div>
				</div>
				<div class="special-value" style="height:68px;">
					<div class="check-value-box temporary-update-department">
							{{#
								if(d.params.deptMsg || d.params.groupMsg) {
									var exitDep = d.params.deptMsg.length ? d.params.deptMsg : [],
										exGgrp = d.params.groupMsg.length ? d.params.groupMsg : [],
										allEx = exitDep.concat(exGgrp);
									layui.each(allEx, function(index,item) {
							}}
								<div class="unit-content">
									{{item.writeusername}}
									<i class="layui-icon layui-icon-close T-event unit" data-target="delUnit" data-deptid="{{item.dataid}}"></i>
								</div>
							{{#
									})
								}
							}}
					</div>
				</div>
			</div>
	</div>
</div>
</script>
<style>
.temporary-viewHtml-content * {
    box-sizing: content-box;
}
.clearfix::after{
	content: '';
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}
.temporary-viewHtml-content .layui-form-item .layui-inline {
	margin-right: 0px;
}
.temporary-viewHtml-content .layui-form-item .layui-inline{
	width: 40%;
}
.temporary-viewHtml-content .layui-form-item .layui-inline span{
	display: block;
    line-height: 40px;
	height: 0px;
	cursor: pointer;
}
.icon-important{
	color: red;
}
.temporary-viewHtml-content .layui-form-item .layui-input-inline {
    width: 66%;
}
.temporary-viewHtml-content .layui-form-switch {
	background: #D2D2D2;
    width: 60%;
}
.temporary-viewHtml-content .layui-form-switch i {
    background-color: #fff;
}
.temporary-viewHtml-content .layui-form-switch em {
    margin-left: 28px;
    color: #fff!important;
}
.temporary-viewHtml-content .layui-form-onswitch em {
    margin-left: 9px !important;
}
.temporary-viewHtml-content .layui-form-onswitch i {
    margin-left: -22px;
}
.temporary-viewHtml-content .layui-form-onswitch {
    border-color: #2669B1;
    background-color: #2669B1;
}
.temporary-viewHtml-content .layui-btn-xs{
	height: 38px;
    background: #2669B1;
    margin-top: -8px;
    border-radius: 5px;
    width: 75px;
    margin-left: 5px;
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
}
.temporary-viewHtml-content .special-content {
	width: 100%;
	margin-bottom: 15px;
}
.temporary-viewHtml-content .special-key {
	overflow: hidden;
	width: 80px;
	float: left;
	padding: 9px 15px;
	text-align: center;
}
.temporary-viewHtml-content .special-value {
	overflow: hidden;
	border: 1px solid #ccc;
	height: 38px;
	border-radius: 6px;
    border: 1px solid rgb(197,197,197);
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
}
.temporary-viewHtml-content .layui-input, .layui-textarea{
	height: 35px;
	border-radius: 6px;
    border: 1px solid rgb(197,197,197);
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
	padding: 0px 0px 0px 10px;
}
.temporary-viewHtml-content .iframeContent {
	width: 100%;
	/* height: 520px; */
	height: 475px;
	margin-bottom: 40px;
}
.temporary-viewHtml-content .iframeContent .temporary-viewHtml-form {
	width: 100%;
	height: 100%;
	overflow: auto;
}
.temporary-viewHtml-content .buttons-area {
	position: absolute;
	bottom: 0px;
	left: 0px;
	width: 100%;
	height: 40px;
	text-align: center;
	margin-top: 10px;
}
.buttons-area button{
	background-color: #2669B1;
}
.temporary-viewHtml-content .check-value-box {
	width: 100%;
	height: 100%;
	overflow-y: auto;
	padding: 2px 2px;
}
.temporary-viewHtml-content .unit-content {
	display: inline-block;
	padding: 2px 5px;
	padding-right: 15px;
	background-color: #ccc;
	position: relative;
	height: 20px;
	line-height: 20px;
}



.temporary-viewHtml-content .unit-content i {
	position: absolute;
	right: 0px;
	top: -2px;
	font-size: 14px;
	cursor: pointer;
	visibility: hidden;
}
/* 滚动条样式 */
::-webkit-scrollbar{
	width: 4px;
	height: 4px;
}
::-webkit-scrollbar-thumb{
	border-radius: 5px;
    -webkit-box-shaow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-track{
	border-radius: 0;
    background: rgba(0,0,0,0.1);
}
.layui-layer{
	border-radius: 8px;
}
.layui-layer .layui-layer-title{
    height: 35px;
    line-height: 35px;
    padding: 0;
    border-bottom: none;
    background: url('/src/style/res/formFill/layer-head.png') no-repeat center center;
}
.formFill-icon{
    display: inline-block;
    width: 3px;
    height: 14px;
    background-color: #FFFFFF;
    vertical-align: middle;
    margin: 0 12px 0 24px;
}
.layui-form-label{
	padding: 8px 14px;
}
.layui-layer-setwin{
    top: 10px;
    right: 11px;
}
.layui-layer-setwin .layui-layer-close1{
    background-position: 0 0;
}
.layui-layer-setwin a{
    width: 18px;
    height: 18px;
    margin: 0;
    background: url('/src/style/res/formFill/layer-close.png') no-repeat center center;
    background-position: 0px 0px;
}
.review-content, .audit-content{
	width: 50%;
	float: left;
	position: relative;
}
.to-review, .to-audit{
	position: absolute;
	top: 0;
	left: 0;
}
.review-value-box, .audit-value-box{
	position: absolute;
	left: 83px;
	display: inline-block;
	width: 360px;
	height: 35px;
	line-height: 20px;
	border-radius: 6px;
	margin-left: 10px;
	overflow-y: scroll;
	border: 1px solid #cccccc;
}
.temporary-viewHtml-content .layui-form-item .layui-inline .review-value-box span{
	display: inline-block;
	padding: 2px 5px;
	height: 20px;
	line-height: 20px;
}
.layui-bg-gray{
	background-color: gray;
}
</style>
<script type="text/html" id="temporaryselectunitTpl">
	{{#
		layui.each(d, function(index,item) {
	}}
		<div class="unit-content">
			<a href="javascript: void(0);">{{item.writeusername}}</a>
			<i class="layui-icon layui-icon-close T-event unit" data-target="delUnit" data-deptid="{{item.dataid}}"></i>
		</div>
	{{#
		})
	}}
</script>
<script type="text/html" id="temporaryselectgroupTpl">
	{{#
		layui.each(d, function(index,item) {
	}}
		<div class="unit-content">
			<a href="javascript: void(0);">{{item.writeusername}}</a>
			<i class="layui-icon layui-icon-close T-event group" data-target="delUnit" data-deptid="{{item.dept_id}}"></i>
		</div>
	{{#
		})
	}}
</script>
<script type="text/html" id="temporaryuploadFilesTpl">
    {{#
        layui.each(d, function(index,item) {
    }}
        <div class="unit-content">
			<a class="T-event" data-target="download" href="javascript: void(0);" data-url="{{item.url}}">{{item.filename}}</a>
            <i class="layui-icon layui-icon-close T-event" data-target="delFile" data-deptid="{{item.servername}}"></i>
        </div>
    {{#
        })
    }}
</script>
<script>
	layui.data.temporaryViewdone = function (d) { 
		layui.use(['admin', 'form', 'laydate', 'upload', 'tools', 'set'], function(){
			var $ = layui.$,
			admin = layui.admin,
			view = layui.view,
			element = layui.element,
			layer = layui.layer,
			laydate = layui.laydate,
			laytpl = layui.laytpl,
			upload = layui.upload,
			setter = layui.setter,
			tools = layui.tools,
			filenames = [],
			form = layui.form;

			layui.factory('set');

			form.render(null, 'temporary-viewHtml-form-group');

			//initDom();

			var selectDep = d.params.deptMsg || [],
				selectGrp = d.params.groupMsg || [],
				originDep = [],
				originGrp = [],
				switchKey = parseInt(d.params.review) || 0;
			$.each(selectDep, function(i,e) {
				e.dept_id = e.dataid;
				originDep.push(e);
			});
			$.each(selectGrp, function(i,e) {
				e.dept_id = e.dataid;
				originGrp.push(e);
			});
			window.selectTable = d.params.formMsg || [];

			if(d.params.id) { //修改
				var exitFileNames = d.params.fileNames || [];
				if(exitFileNames.length > 0) {
					filenames = exitFileNames;
					var getTpl = temporaryuploadFilesTpl.innerHTML;
					var $tplC =$('.temporary-update-files');
					laytpl(getTpl).render(exitFileNames, function(html){
						$tplC.html(html);
					});
				}
			}

			//dom初始化
			function initDom() {
				var commonMin = { year: 1900, month: 0, date: 1},
					commonMax = { year: 2099, month: 11, date: 31};
				var startDate = laydate.render({
					elem: '.temporary-form-group-startDate',
					done: function (value, date) {
						if(!!value) {
							endDate.config.min = {
								year:date.year,
								month:date.month-1, 
								date: date.date,
							};
						}else {
							endDate.config.min = commonMin;
							endDate.config.max = commonMax;
						}
					}
				});
				var endDate = laydate.render({
					elem: '.temporary-form-group-endDate',
					done: function (value, date) {
						if(!!value) {
							startDate.config.max = {
								year: date.year,
								month: date.month - 1,
								date: date.date,
							} 
						}else {
							startDate.config.min = commonMin;
							startDate.config.max = commonMax; 
						}
					}
				});
			};

			//加载编辑时已选择的表单
			var mainIframe = document.getElementById('mainFormIframe');
			$(mainIframe).load(function(){
				if(d.params.formMsg && d.params.formMsg.length > 0){
					var formContanier = mainIframe.contentWindow.document.querySelector('.select-nodes-list ul');
					var chooseNodes = d.params.formMsg;
					var lihtml = '';
					if(chooseNodes && chooseNodes.length > 0){
						for(var i = 0; i < chooseNodes.length; i++){
							if(i == 0){
								lihtml += "<li class='liactive' id='"+chooseNodes[i].id+"' data-model='normal' data-tablename='"+chooseNodes[i].tablename+"' data-formid='"+chooseNodes[i].form_id+"' data-id='"+chooseNodes[i].id+"' data-html='"+chooseNodes[i].html+"'>"+chooseNodes[i].formname+"</li>"
							}else{
								lihtml += "<li data-model='normal' id='"+chooseNodes[i].id+"' data-tablename='"+chooseNodes[i].tablename+"' data-formid='"+chooseNodes[i].form_id+"' data-id='"+chooseNodes[i].id+"' data-html='"+chooseNodes[i].html+"'>"+chooseNodes[i].formname+"</li>"
							}
						}
						formContanier.innerHTML = lihtml;
						var firstLi = formContanier.querySelector('li');
						firstLi.click();
					}
                }
                var buttons = $(mainIframe.contentWindow.document).find('button');
                $.each(buttons, function(index, el) {
                    $(el).attr('disabled', 'true');
                })
			})
		});
	}

</script>